package com.shiguiwu.springmybatis.designpattern.strategy.service;

import lombok.extern.slf4j.Slf4j;

/**
 * @description: 优惠服务
 * @author: stone
 * @date: Created by 2021/9/9 16:19
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.strategy.service
 */
@Slf4j
public class CouponDiscountService {


    public double discountAmount(int type, double typeContent, double skuPrice, double typeExt) {

        log.info(" 优惠策略是 {}， 优惠的金额是{}，原来价格是{}", type, typeContent, skuPrice);
        //直减
        if (0 == type) {
            return skuPrice - typeContent;
        }
        //满减
        if (1 == type) {
            if (skuPrice < typeExt) {
                return skuPrice;
            }
            return skuPrice - typeContent;
        }

        //折扣间
        if (2 == type) {
            return skuPrice * typeContent;
        }

        //n元购
        if (3 == type) {
            return typeContent;
        }

        return 0D;

    }
}
